import java.awt.Color;
import java.awt.Container;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Index {
	public static JFrame frame;

	public static void main(String[] args) {
		new Index();
    }
	
	public Index(){
		try {
			Class.forName("org.sqlite.JDBC");
		} catch (ClassNotFoundException e2) {
			// TODO Auto-generated catch block
			e2.printStackTrace();
		}

		try {
			
			Global.conn = DriverManager.getConnection("jdbc:sqlite:db1");
			Global.statement = Global.conn.createStatement(
			          ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
			
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		
		
		frame = new JFrame();
		
		//Stavljanje bijele pozadine
		Container con = frame.getContentPane();
		con.setBackground(Color.white);
		
		//Namjestanje layout-a na XY
		frame.setLayout(new XYLayout());
		
		//Namjestanje fullscreen-a
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        
        //Dobivanje velicine ekrana
    	Global.displayX = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
    	Global.displayY = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
    	
    	System.out.println(Global.displayX + " " + Global.displayY);

    	
    	
    	JPanel appJPanel = new AppJPanel();
    	frame.add(appJPanel);
    	
    	/* 
    	 * SLIKA ZA KASNIJE
    	 
    	PictureLabel backgroundImage = new PictureLabel();
    	backgroundImage.setLocation(-5, -5);
		frame.add(backgroundImage);
    	
    	 */
    	
    	
    	 //Namjestanje da li se vidi toolbar
        frame.setUndecorated(true);
        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {
        	public void windowClosing(WindowEvent e){
        		new ReallyExit();
        	}
		});
        frame.setVisible(true);
        
		
		
        
      
        
	}
	
	public void processWindowEvent(WindowEvent event) {
        if(event.getID() == WindowEvent.WINDOW_CLOSING)
            System.exit(0);
    }
	
	

}


//0 = login
//1 = blagajna
//2 = login u izbornik